﻿using EBA.IoC;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EBA.Json
{
    /// <summary>
    /// JsonSerializer factory
    /// </summary>
    public static class JsonSerializer
    {
        /// <summary>
        /// Get a <see cref="IJsonSerialize"/> instance, returns a <see cref="DataContractJsonSerializerWrapper"/> instance when no implmention is exported as <see cref="IJsonSerialize"/>.
        /// </summary>
        /// <returns></returns>
        public static IJsonSerializer GetInstance()
        {
            IJsonSerializer serializer;
            if (Container.Default.TryGetExport<IJsonSerializer>(out serializer))
            {
                return serializer;
            }
            else
            {
                return new DataContractJsonSerializerWrapper();
            }
        }

    }
}
